﻿using Microsoft.AspNetCore.Mvc;

namespace TestApi.Controllers;

/// <summary>
/// 测试Param 参数示例
/// </summary>
[ApiController,Route("api/[controller]"),ApiExplorerSettings(GroupName = "v1")]
public class ParamTestController : Controller
{
    [HttpGet("null")]
    public IActionResult Index()
    {
        return Ok("Success");
    }
    
    [HttpGet("by/{id}")]
    public IActionResult GetByInt(int id)
    {
        return Ok("Success");
    }
    
    [HttpGet("int")]
    public IActionResult GetInt([FromQuery]int id=0)
    {
        return Ok("Success");
    }
    
    [HttpGet("long")]
    public IActionResult GetLong([FromQuery]long id=0)
    {
        return Ok("Success");
    }
    
    [HttpGet("string")]
    public IActionResult GetString([FromQuery]string id)
    {
        return Ok("Success");
    }
    
    /// <summary>
    /// 数组字符串
    /// </summary>
    /// <param name="array">数组字符串</param>
    /// <returns></returns>
    [HttpGet("string/list")]
    public IActionResult GetListString([FromQuery]List<string> array)
    {
        return Ok("Success");
    }
    
    [HttpGet("string/int")]
    public IActionResult GetListInt([FromQuery]List<int> array)
    {
        return Ok("Success");
    }
    
    [HttpGet("string/long")]
    public IActionResult GetListLong([FromQuery]List<long> array)
    {
        return Ok("Success");
    }
    
    [HttpGet("array/object")]
    public IActionResult GetObject([FromQuery]WeatherForecastController.MyClass objects)
    {
        return Ok("Success");
    }
        
    [HttpGet("array/list")]
    public IActionResult GetObjectList([FromQuery]List<WeatherForecastController.MyClass> list)
    {
        return Ok("Success");
    }
}